﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace RenameTracker
{
    /// <summary>
    /// Handy wrapper for a TFS Changeset object that only represents one item
    /// </summary>
    public class ChangeInfo
    {
        public ChangeInfo(Changeset c)
            : this(c.ChangesetId, c.CreationDate, c.Owner, c.Changes[0].ChangeType, c.Changes[0].Item.ServerItem, 
                   c.Changes[0].Item.DeletionId, c.VersionControlServer)
        { }

        protected ChangeInfo(ChangeInfo ci)
            : this(ci.Version, ci.Date, ci.Owner, ci.ChangeType, ci.Path, ci.DeletionId, ci.Server)
        { }
        
        protected ChangeInfo(int version, DateTime date, string owner, ChangeType changeType, string path, int deletionId, VersionControlServer server)
        {
            Version = version;                   
            Date = date;
            Owner = owner;
            ChangeType = changeType;
            Path = path;
            DeletionId = deletionId;
            Server = server;
        }

        // standard stuff pulled directly from TFS
        public int Version { get; private set; }
        public int DeletionId { get; private set; }
        public DateTime Date { get; private set; }
        public string Owner { get; private set; }
        public ChangeType ChangeType { get; private set; }
        public string Path { get; private set; }
        public VersionControlServer Server { get; private set; }


        public override string ToString()
        {
            return string.Format("{0};{1};X{2}\n{3} by {4}", Path, Version, DeletionId, Date, Owner);
        }
    }
}
